<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小康同学</title>
    <style>
        .active{
            color: rgb(53, 114, 206);
            text-align: center;
            font-size: 20px;
            margin-top: 40px;
            
        }
    </style>
</head>

<body>
    <h1 class="active"></h1>
    <h2 class="active"></h2>
    <script>
        var timer = setInterval(auto, 1000)
        auto()
        function auto() {
            let mony = 0
            let oh1 = document.getElementsByTagName('h1')[0]
            let oh2 = document.getElementsByTagName('h2')[0]
            var newTimes = new Date().getTime();//时间戳
            var oldTimes = new Date("2023/3/1").getTime();//时间戳
            let time = newTimes - oldTimes
            time = parseInt(time / 1000)

            //获取天
            var d = parseInt((time/86400));
            // 获取小时
            var h = parseInt((time % 86400) / 3600);
            // 获取分钟
            var m = parseInt((time % 86400 % 3600) / 60);
            // // 获取秒数
            var s = parseInt(time % 60);
            oh1.innerHTML = `已成功戒烟${d}天${h}小时${m}分钟${s}秒`
            oh2.innerHTML = `预计节省${d*10}元${h}角${m}分`
            
        }
    </script>
</body>

</html>